import Vue from 'vue'
import Router from 'vue-router'
// import store from '@/store'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import asyncRouterMaps from './asyncRouterMap'
import constantRouterMaps from './constantRouterMap'

NProgress.configure({ showSpinner: false })

Vue.use(Router)

const router = new Router({
  routes: [
    ...constantRouterMaps,
    ...asyncRouterMaps
  ]
})
export default router

router.beforeEach((to, from, next) => {
  // if (to.meta.isLogin && !store.getters.token) {
  //   next('/login')
  //   return false
  // }
  // if (to.meta.inShop) {
  //   if (!store.getters.currentShopID) {
  //     next('/organizationList')
  //     return false
  //   }
  // }
  NProgress.start()
  next()
})
router.afterEach(() => {
  NProgress.done()
})
